﻿Public Class Formlogin
    Private Sub ButtonX1_Click(sender As Object, e As EventArgs) Handles ButtonX1.Click
        If txtname.Text.Trim = "" Then
            MsgBox("Please input Username....!")
            txtname.Focus()
            Exit Sub
        End If
        If txtpwd.Text.Trim = "" Then
            MsgBox("Please input Password To login......!")
            txtpwd.Focus()
            Exit Sub
        End If
        CMD.Parameters("@name") = txtname.Text
        CMD.Parameters("@pwd") = txtpwd.Text
        Dim count = CMD.ExecuteScalar("SELECT count(*) from TBL_USER WHERE LOG_NAME=@name AND PWD=@pwd")
        If count > 0 Then
            CMD.Parameters("@name") = txtname.Text
            CMD.Parameters("@pwd") = txtpwd.Text
            Dim rs = CMD.ExecuteDataReader("select u.EMP_ID ,u.U_PERMIS,e.EMP_CODE from TBL_USER u inner join TBL_EMPLOYEE e on(u.EMP_ID=e.EMP_ID) WHERE u.LOG_NAME=@name AND u.PWD=@pwd ")
            While rs.Read
                txtemp_id.Text = rs(0)
                txtpermis.Text = rs(1)
                txtcode.Text = rs(2)
            End While
            rs.Close()
            process.Timer1.Interval = 1500
            process.ShowDialog()
            Me.Hide()
            MDIParent1.Show()

        Else
            MsgBox("Your usename or password Incorrect....!")
        End If
    End Sub

    Private Sub ButtonX2_Click(sender As Object, e As EventArgs) Handles ButtonX2.Click
        Me.Close()
    End Sub
    Private Sub Formlogin_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class